package com.lazy.dao;

import com.lazy.entity.Bicycle;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface BicycleDao {

    @Insert("insert into t_bicycle values(null,#{bicycleNum},#{bicycleType},#{bicycleBuyTime},#{bicycleStatus})")
    boolean addBicycle(Bicycle bicycle);

    @Update("update t_bicycle set bicycle_type=#{bicycleType},bicycle_status=#{bicycleStatus}," +
            "bicycle_buy_time=#{bicycleBuyTime} where id=#{id}")
    boolean upBicycle(Bicycle bicycle);

    @Select("select * from t_bicycle")
    @Results(id = "PageBicycle", value = {
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "bicycleNum", column = "bicycle_Num"),
            @Result(property = "bicycleType", column = "bicycle_type"),
            @Result(property = "bicycleStatus", column = "bicycle_status"),
            @Result(property = "bicycleBuyTime", column = "bicycle_buy_time"),
            @Result(property = "BicycleAType",column = "bicycle_type",
            one = @One(select = "com.lazy.dao.BicycleTypeDao.getBicycleTypeById"))
    })
    List<Bicycle> PageBicycle();

    @Delete("delete from t_bicycle where id=#{id}")
    boolean deleteBicycle(Integer id);
}

